/** @jsxImportSource @emotion/react */
import * as React from "react";
import {
  CCell, Cell, Input, InputLine, LineColumn, Select, Table, TableBody, TableRow, Text, TextArea, useTheme,
} from "customize-easy-ui-component";
import {InspectRecordLayout, InternalItemProps, RepLink, useItemInputControl} from "../../common/base";
import {config设备概况} from "./orcBase";
import {useMeasureInpFilter} from "../../common/hooks";
import {TailMenRowIspCheck} from "../../contain/rarelyVary";
import {useThreeColumnView} from "../../hook/useThreeColumnSubr";


interface Props  extends InternalItemProps{
  label?: string;
  config?: any[];    //有配置模式的 : 表对象的默认取值；
}
export const itemA下结论=['检验结论','检验日期','检验日期1','新下检日','结论说明'];
// const itemA下结论m=itemA下结论.concat(['工作压力','额定温度']);
//结论页的：
export const ConclusionglRef=
    React.forwardRef((
        { children, show ,alone=true,redId,nestMd,label,}:Props,  ref
    ) => {
      const [getInpFilter]=useMeasureInpFilter(null,itemA下结论,);
      const {inp, setInp} = useItemInputControl({ ref });
      return <InspectRecordLayout inp={inp} setInp={setInp} getInpFilter={getInpFilter} show={show} redId={redId}
                                  nestMd={nestMd} alone={alone} label={label!}>
        <Text variant="h5">{label}：</Text> 必须符合要求才会有证书的。
        <InputLine  label='检验结论' >
          <Select inputSize="md" css={{minWidth:'140px',fontSize:'1.3rem',padding:'0 1rem'}}
                  value={ inp?.检验结论  ||''} onChange={e => setInp({ ...inp, 检验结论: e.currentTarget.value||undefined}) }>
            <option></option>
            <option>符合要求</option>
            <option>不符合要求</option>
          </Select>
        </InputLine>
        <LineColumn column={4}>
          <InputLine label='设置检验日期'>
            <Input value={inp?.检验日期 || ''} type='date'
                   onChange={e => setInp({...inp, 检验日期: e.currentTarget.value})}/>
          </InputLine>
          <InputLine  label='检验起始日期' >
            <Input  value={inp?.检验日期1 ||''}  type='date'
                    onChange={e => setInp({ ...inp, 检验日期1: e.currentTarget.value}) } />
          </InputLine>
          <InputLine  label='下次检验日期' >
            <Input  value={inp?.新下检日 ||''}  type='date'
                    onChange={e => setInp({ ...inp, 新下检日: e.currentTarget.value}) } />
          </InputLine>
        </LineColumn>
        现场修理、改造施工过程概述：
        <TextArea  value={inp?.结论说明 ||''} rows={9}
                   onChange={e => setInp({ ...inp, 结论说明: e.currentTarget.value||undefined}) } />
      </InspectRecordLayout>;
    });

//结论报告
export const ConclusionglRefVw= ({ orc, rep } : { orc: any, rep: any}
) => {
  const theme = useTheme();
  //但是不能用：加embed: { 0:  <CCell rowSpan={4}>性能参数</CCell>,  }, 需分解为2个表格/列数不同。const config设备概况上=config设备概况.slice(0, 14);
  // const renderUpper=usePrefixDataTable({config: config设备概况, orc, rep, slash:true});
  const [_,renderUpper,renderGaizao]=useThreeColumnView({orc, config:config设备概况,slash:true,split:[1,16]});
  return <>
    <div css={{"@media print": {paddingBottom: '3.5rem', pageBreakInside: 'avoid'}}}>
      <Text id={'Conclusion'} variant="h2" css={{textAlign: 'center', marginTop: '1rem',
      }}>工业锅炉修理、改造监督检验结论报告</Text>
      <div css={{display: 'flex', justifyContent: 'space-between'}}>
        <Text></Text>
        <Text>报告编号：{rep.isp.no}</Text>
      </div>
    </div>
    <Table fixed={ ["14.1%", "19%", "23%", "14.1%", "8%", "%"]  }
           css={{borderCollapse: 'collapse', "@media print": {marginTop: '-3.5rem'}}} tight miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'Survey'}>
          <TableRow >
            <CCell colSpan={6}><Text css={{fontWeight: 800}}>锅炉基本情况</Text></CCell>
          </TableRow>
          {renderUpper}
          <TableRow >
            <CCell colSpan={6}><Text css={{fontWeight: 800}}>修理、改造单位及现场施工过程</Text></CCell>
          </TableRow>
          {renderGaizao}
        </RepLink>
        <RepLink rep={rep} tag={'Conclusion'}>
          <TableRow >
            <CCell>监检开始日期</CCell>
            <CCell colSpan={2}>{orc?.检验日期1}</CCell>
            <CCell>监检结束日期</CCell>
            <CCell colSpan={2}>{orc?.检验日期}</CCell>
          </TableRow>
          <TableRow>
            <Cell split={true} colSpan={6}><div css={{minHeight: '2rem', whiteSpace: 'pre-wrap'}}>
              现场修理、改造施工过程概述：<br/>
              {orc.结论说明 ?? '／' }
            </div></Cell>
          </TableRow>
          <TableRow >
            <CCell>监督检验依据</CCell>
            <CCell colSpan={5}>《锅炉安全技术规程》TSG11-2020</CCell>
          </TableRow>
        </RepLink>
      </TableBody>
    </Table>
    {/*{检验结论DzglW({theme, orc, rep,nextjycl:'检验'})}*/}
    <TailMenRowIspCheck cap={'监检'} orc={orc} rep={rep} href={`/report/${rep?.modeltype}/ver/${rep?.modelversion}/${rep?.id}/Conclusion#Conclusion`}>
    </TailMenRowIspCheck>
  </>;
};
